//
//  PlayViewController.m
//  KeleAppProject
//
//  Created by 周岑 on 2018/1/15.
//  Copyright © 2018年 Cen Zhou. All rights reserved.
//

#import "PlayViewController.h"
#import "ChildNavView.h"


#import "FinalListViewController.h"
#import "MonthListViewController.h"
#import "WeekListViewController.h"
#import "DayListViewController.h"

@interface PlayViewController ()<UIScrollViewDelegate>

@property (nonatomic, strong) NSArray *playTitleArray;
@property (nonatomic, strong) NSArray *playControllerArray;

@end

@implementation PlayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    self.view.backgroundColor = [UIColor redColor];
    self.scrollView.scrollEnabled = NO;
    [self loadSubviewsOnPlayViewController];
    [self addChildControllersWithArray:self.playControllerArray];
    [self loadSubviewsOnHomeWithScrollHeight:KLScreenH-NaviH-TabbarH y:48*HEIGHT titleArr:self.playControllerArray];
}

// 加载控件
- (void)loadSubviewsOnPlayViewController{
    ChildNavView *childNav = [[ChildNavView alloc]initWithFrame:CGRectMake(0, 0, KLScreenW, 48*HEIGHT)];
    childNav.backgroundColor = [UIColor whiteColor];
    childNav.delegateSignal = [RACSubject subject];
    [childNav.delegateSignal subscribeNext:^(NSDictionary *x) {
        [self.scrollView setContentOffset:CGPointMake(KLScreenW * [x[@"index"] integerValue], 0) animated:YES];
        [self setUpOneChildViewController:[x[@"index"] integerValue]];
    }];
    [self.view addSubview:childNav];
}

- (NSArray *)playTitleArray{
    if (!_playTitleArray) {
        _playTitleArray = [NSArray arrayWithObjects:@"日榜",@"月榜",@"周榜",@"总榜", nil];
    }
    return _playTitleArray;
}

- (NSArray *)playControllerArray{
    if (!_playControllerArray) {
        _playControllerArray = [NSArray arrayWithObjects:@"DayListViewController",@"WeekListViewController",@"MonthListViewController",@"FinalListViewController", nil];
    }
    return _playControllerArray;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
